import './App.css';
import { useState } from 'react'
const Button = () => {
  // 添加一个状态变量
  // const 状态变量
  // setCount 修改状态变量的方法

  const [count, setCount] = useState(0);
  const handleClick = () => {
    setCount(count + 1)
  }

  // 修改对象
  const [form, setForm] = useState({ name: 'jack' })
  const handleClickForm = () => {
    setForm({ ...form, name: 'tom' })
  }

  return (
    <>
      <button onClick={handleClick}>useState{count}</button>
      <button onClick={handleClickForm}>useState对象{form.name}</button>
    </>
  )
}

function App() {
  return (
    <div className="App">
      <Button />
    </div>
  );
}

export default App;
